package stub;

import java.rmi.RemoteException;

import databaseservice.UserPOService;
import info.LogoffResult;
import info.RegisterResult;
import info.UserRole;
import po.UserPO;
import businesslogic.network.RMIStubClient;
import businesslogicservice.UserBLService;

public class UserBLService_Stub implements UserBLService {

	UserPOService userPOService;
	
	public UserBLService_Stub(RMIStubClient client){
		this.userPOService = client.userPOService;
	}
	
	@Override
	public boolean check(UserPO user) {
		// TODO Auto-generated method stub
		boolean isUser = false;
		
		try {
			System.out.println(userPOService.search(user));
			isUser = !(userPOService.search(user).getRole() == UserRole.NULL);
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if(isUser)
			return true;
		else
			return false;
	}

	@Override
	public RegisterResult register(UserPO user) {
		// TODO Auto-generated method stub
		return RegisterResult.REGISTER_SUCCESS;
	}

	@Override
	public LogoffResult logOff(UserPO user) {
		// TODO Auto-generated method stub
		return LogoffResult.LOGOFF_SUCCESS;
	}

}
